package com.loocan.answer.utils

import com.loocan.answer.QuizApplication

fun Int.dp(): Int {
    return (this * QuizApplication.instance.resources.displayMetrics.density + 0.5f).toInt()
}

fun Float.dp(): Int {
    return (this * QuizApplication.instance.resources.displayMetrics.density + 0.5f).toInt()
}

// 根据手机的分辨率从 px(像素) 的单位 转成为 dp
fun Int.px2dip(): Int {
    return (this / QuizApplication.instance.resources.displayMetrics.density + 0.5f).toInt()
}

fun Float.px2dip(): Int {
    return (this / QuizApplication.instance.resources.displayMetrics.density + 0.5f).toInt()
}
